package com.bjsdzk.common.core;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

/**
 * 统一API响应结果封装
 */
public class Result<T> {
    @ApiModelProperty(value = "code：200 成功，400 失败，403 未认证，404 接口不存在， 500 接口内部错误")
    private int code;
    @ApiModelProperty(value = "返回信息")
    private String message;
    @ApiModelProperty(value = "返回实体")
    private T data;

    public Result setCode(ResultCode resultCode) {
        this.code = resultCode.code;
        return this;
    }

    public int getCode() {
        return code;
    }

    public Result setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }

    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }

    public Result setMessage(String message) {
        this.message = message;
        return this;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

}
